package com.yx.backstage.manager;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yx.backstage.converter.ManagerConverter;
import com.yx.backstage.model.Manager;
import com.yx.backstage.model.param.ManagerParam;
import com.yx.backstage.model.vo.ManagerVo;
import com.yx.backstage.service.ManagerService;
import com.yx.backstage.config.global.CommonResult;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author YangXiong
 */
@Component
public class ManagerManager {
    @Resource
    private ManagerService managerService;

    public CommonResult<List<ManagerVo>> pageList(ManagerParam param) {
        Page<Manager> managerPage = new Page<>();
        managerPage.setCurrent(param.getCurrentPage());
        managerPage.setSize(param.getTotalPage());
        Page<Manager> page = managerService.page(managerPage);
        List<ManagerVo> result = ManagerConverter.handlerPageResult(page.getRecords());
        return CommonResult.success(result, page.getTotal());
    }

}
